package com.jsz.peini.bean.task;

import io.swagger.annotations.ApiModelProperty;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import com.jsz.peini.bean.user.UserInfo;
import com.jsz.peini.common.util.CommonUtils;
import com.jsz.peini.common.util.ThreadUtil;
import com.jsz.peini.vo.ThreadInfo;

public class PartyInfo {
	@ApiModelProperty(hidden=true)
    private Integer id;

	@ApiModelProperty(hidden=true)
    private String userId;
    
    //不持久化
    @ApiModelProperty(hidden=true)
    private int memberNum;
    @ApiModelProperty(hidden=true)
    private UserInfo userInfo;
    @ApiModelProperty(hidden=true)
    private List<Map<String,String>> members;
    
    
    @ApiModelProperty(hidden=true)
    private Map<String,Object> sellerInfo;
    
	@NotNull
    @ApiModelProperty("0:非官方  1:官方")
    private Boolean official;

    @Min(2)
    @ApiModelProperty("最大人数")
    private Integer maxNum;
    

    @ApiModelProperty("买单方式： 1:发起人买单 2:AA 3:男A女免")
    @Range(min=1,max=3)
    @NotNull
    private Integer payType;

    @Range(min=0,max=1)
    private Integer prePay;

    @ApiModelProperty(hidden=true)
    private Integer partyStatus;

    @ApiModelProperty("目的，最大长度12")
    @Length(max=12)
    private String purpose;

    @ApiModelProperty("省份")
    private Integer province;
    @ApiModelProperty("城市")
    private Integer city;
    @ApiModelProperty("县区")
    private Integer conty;
    private Double xpoint;
    private Double ypoint;
    @ApiModelProperty("1:指定商家  2:大概地点")
    @Range(min=1,max=2)
    private Integer sellerType;
    
    @ApiModelProperty("店铺id")
    private Integer sellerInfoId;
    
    @ApiModelProperty("1:商家名称")
    private String sellerName;
    @ApiModelProperty("1:商家地点")
    private String sellerAddress;
    
    @ApiModelProperty(hidden=true)
    private String sellerSmallName;
    @ApiModelProperty(hidden=true)
    private Integer sellerSmallType;
    @ApiModelProperty(hidden=true)
    private String sellerBigName;
    @ApiModelProperty(hidden=true)
    private Integer sellerBigType;
    @ApiModelProperty(hidden=true)
    private Date createTime;

    @ApiModelProperty(value="聚会约定时间",example="2016-01-01 11:11:11")
    private Date appointedTime;

    @ApiModelProperty(hidden=true)
    private Date cancelTime;

    @ApiModelProperty(hidden=true)
    private Date endTime;
    @Length(max=255)
    @ApiModelProperty("聚会描述")
    private String description;
    @Length(max=100)
    @ApiModelProperty("图片网址")
    private String pic;

    @ApiModelProperty(hidden=true)
    private String cancelReason;

    @ApiModelProperty(hidden=true)
    private Boolean isdelete;

    @ApiModelProperty(hidden=true)
    private Integer orderId;
    
    public UserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Boolean getOfficial() {
        return official;
    }

    public void setOfficial(Boolean official) {
        this.official = official;
    }

    public Integer getMaxNum() {
        return maxNum;
    }

    public void setMaxNum(Integer maxNum) {
        this.maxNum = maxNum;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public Integer getPrePay() {
        return prePay;
    }

    public void setPrePay(Integer prePay) {
        this.prePay = prePay;
    }

    public Integer getPartyStatus() {
        return partyStatus;
    }

    public void setPartyStatus(Integer partyStatus) {
        this.partyStatus = partyStatus;
    }

    public String getPurpose() {
        return purpose;
    }

    public void setPurpose(String purpose) {
        this.purpose = purpose;
    }

    public Integer getProvince() {
        return province;
    }

    public void setProvince(Integer province) {
        this.province = province;
    }

    public Integer getCity() {
        return city;
    }

    public void setCity(Integer city) {
        this.city = city;
    }

    public Integer getConty() {
        return conty;
    }

    public void setConty(Integer conty) {
        this.conty = conty;
    }

    public Double getXpoint() {
        return xpoint;
    }

    public void setXpoint(Double xpoint) {
        this.xpoint = xpoint;
    }

    public Double getYpoint() {
        return ypoint;
    }

    public void setYpoint(Double ypoint) {
        this.ypoint = ypoint;
    }

    public Integer getSellerType() {
        return sellerType;
    }

    public void setSellerType(Integer sellerType) {
        this.sellerType = sellerType;
    }

    public Integer getSellerInfoId() {
        return sellerInfoId;
    }

    public void setSellerInfoId(Integer sellerInfoId) {
        this.sellerInfoId = sellerInfoId;
    }

    public String getSellerSmallName() {
        return sellerSmallName;
    }

    public void setSellerSmallName(String sellerSmallName) {
        this.sellerSmallName = sellerSmallName;
    }

    public Integer getSellerSmallType() {
        return sellerSmallType;
    }

    public void setSellerSmallType(Integer sellerSmallType) {
        this.sellerSmallType = sellerSmallType;
    }

    public String getSellerBigName() {
        return sellerBigName;
    }

    public void setSellerBigName(String sellerBigName) {
        this.sellerBigName = sellerBigName;
    }

    public Integer getSellerBigType() {
        return sellerBigType;
    }

    public void setSellerBigType(Integer sellerBigType) {
        this.sellerBigType = sellerBigType;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    
    @SuppressWarnings("deprecation")
	public int getWeekDayOfAppointedTime() {
        return appointedTime.getDay();
    }

    public Date getAppointedTime() {
        return appointedTime;
    }

    public void setAppointedTime(Date appointedTime) {
        this.appointedTime = appointedTime;
    }

    public Date getCancelTime() {
        return cancelTime;
    }

    public void setCancelTime(Date cancelTime) {
        this.cancelTime = cancelTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getCancelReason() {
        return cancelReason;
    }

    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }

    public Boolean getIsdelete() {
        return isdelete;
    }

    public void setIsdelete(Boolean isdelete) {
        this.isdelete = isdelete;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

	public List<Map<String, String>> getMembers() {
		return members;
	}

	public void setMembers(List<Map<String, String>> members) {
		this.members = members;
	}

	public int getMemberNum() {
		return memberNum;
	}

	public void setMemberNum(int memberNum) {
		this.memberNum = memberNum;
	}

	public Map<String,Object> getSellerInfo() {
		return sellerInfo;
	}

	public void setSellerInfo(Map<String,Object> sellerInfo) {
		this.sellerInfo = sellerInfo;
	}

	public String getSellerName() {
		return sellerName;
	}

	public void setSellerName(String sellerName) {
		this.sellerName = sellerName;
	}

	public String getSellerAddress() {
		return sellerAddress;
	}

	public void setSellerAddress(String sellerAddress) {
		this.sellerAddress = sellerAddress;
	}
	
	/**
	 * 用户和商家之间的距离
	 */
	public String getDistance(){
		ThreadInfo threadInfo = ThreadUtil.getThreadInfo();
		Double xpoint = threadInfo.getXpoint();
		Double ypoint = threadInfo.getYpoint();
		if(xpoint == null || ypoint == null || this.getXpoint() == null || this.getYpoint()==null){
			return "无法获取";
		}
		int distance = CommonUtils.contrastMap(xpoint,ypoint,this.getXpoint(),this.getYpoint());
		if(distance < 1000){
			return distance + "m";
		}else{
			return (distance/10)/100.0 + "km";
		}
	}
}